// ========================================================================= //

// includes
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include "string.h"
#include "limits.h"
#include "float.h"



#define JOTAI_NUM_RANDS_ 25

const unsigned rand_primes[JOTAI_NUM_RANDS_] = {179, 103, 479, 647, 229, 37, 271, 557, 263, 607, 18743, 50359, 21929, 48757, 98179, 12907, 52937, 64579, 49957, 52567, 507163, 149939, 412157, 680861, 757751};

int next_i() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_];
}

float next_f() {
  int counter = 0;
  return rand_primes[(++counter)%JOTAI_NUM_RANDS_] / 757751.0F;
} 


// Usage menu
void usage() {
    printf("%s", "Usage:\n\
    prog [ARGS]\n\
\nARGS:\n\
       0            int-bounds\n\
       1            big-arr\n\
       2            big-arr-10x\n\
       3            empty\n\
\n\
");

}


// ------------------------------------------------------------------------- //

#define NULL ((void*)0)
typedef unsigned long size_t;  // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__;  // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef  struct TYPE_4__   TYPE_2__ ;
typedef  struct TYPE_3__   TYPE_1__ ;

/* Type definitions */
struct TYPE_3__ {int freq; } ;
struct TYPE_4__ {TYPE_1__ clock; } ;
struct sja1000_priv {int /*<<< orphan*/  write_reg; int /*<<< orphan*/  read_reg; int /*<<< orphan*/  cdr; int /*<<< orphan*/  ocr; TYPE_2__ can; } ;
struct sja1000_platform_data {int osc_freq; int /*<<< orphan*/  cdr; int /*<<< orphan*/  ocr; } ;

/* Variables and functions */
#define  IORESOURCE_MEM_16BIT 130 
#define  IORESOURCE_MEM_32BIT 129 
#define  IORESOURCE_MEM_8BIT 128 
 unsigned long IORESOURCE_MEM_TYPE_MASK ; 
 int /*<<< orphan*/  sp_read_reg16 ; 
 int /*<<< orphan*/  sp_read_reg32 ; 
 int /*<<< orphan*/  sp_read_reg8 ; 
 int /*<<< orphan*/  sp_write_reg16 ; 
 int /*<<< orphan*/  sp_write_reg32 ; 
 int /*<<< orphan*/  sp_write_reg8 ; 

__attribute__((used)) static void sp_populate(struct sja1000_priv *priv,
			struct sja1000_platform_data *pdata,
			unsigned long resource_mem_flags)
{
	/* The CAN clock frequency is half the oscillator clock frequency */
	priv->can.clock.freq = pdata->osc_freq / 2;
	priv->ocr = pdata->ocr;
	priv->cdr = pdata->cdr;

	switch (resource_mem_flags & IORESOURCE_MEM_TYPE_MASK) {
	case IORESOURCE_MEM_32BIT:
		priv->read_reg = sp_read_reg32;
		priv->write_reg = sp_write_reg32;
		break;
	case IORESOURCE_MEM_16BIT:
		priv->read_reg = sp_read_reg16;
		priv->write_reg = sp_write_reg16;
		break;
	case IORESOURCE_MEM_8BIT:
	default:
		priv->read_reg = sp_read_reg8;
		priv->write_reg = sp_write_reg8;
		break;
	}
}

// ------------------------------------------------------------------------- //

int main(int argc, char *argv[]) {

    if (argc != 2) {
        usage();
        return 1;
    }

    int opt = atoi(argv[1]);
    switch(opt) {


    // int-bounds
    case 0:
    {
          // static_instructions_O0 : 44
          // dynamic_instructions_O0 : 44
          // ------------------------------- 
          // static_instructions_O1 : 25
          // dynamic_instructions_O1 : 25
          // ------------------------------- 
          // static_instructions_O2 : 25
          // dynamic_instructions_O2 : 25
          // ------------------------------- 
          // static_instructions_O3 : 25
          // dynamic_instructions_O3 : 25
          // ------------------------------- 
          // static_instructions_Ofast : 25
          // dynamic_instructions_Ofast : 25
          // ------------------------------- 
          // static_instructions_Os : 25
          // dynamic_instructions_Os : 25
          // ------------------------------- 
          // static_instructions_Oz : 25
          // dynamic_instructions_Oz : 25
          // ------------------------------- 

          unsigned long resource_mem_flags = 100;
        
          int _len_priv0 = 1;
          struct sja1000_priv * priv = (struct sja1000_priv *) malloc(_len_priv0*sizeof(struct sja1000_priv));
          for(int _i0 = 0; _i0 < _len_priv0; _i0++) {
              priv[_i0].write_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].read_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].can.clock.freq = ((-2 * (next_i()%2)) + 1) * next_i();
        
        
        
          }
        
          int _len_pdata0 = 1;
          struct sja1000_platform_data * pdata = (struct sja1000_platform_data *) malloc(_len_pdata0*sizeof(struct sja1000_platform_data));
          for(int _i0 = 0; _i0 < _len_pdata0; _i0++) {
              pdata[_i0].osc_freq = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          sp_populate(priv,pdata,resource_mem_flags);
          free(priv);
          free(pdata);
        
        break;
    }


    // big-arr
    case 1:
    {
          // static_instructions_O0 : 44
          // dynamic_instructions_O0 : 44
          // ------------------------------- 
          // static_instructions_O1 : 25
          // dynamic_instructions_O1 : 25
          // ------------------------------- 
          // static_instructions_O2 : 25
          // dynamic_instructions_O2 : 25
          // ------------------------------- 
          // static_instructions_O3 : 25
          // dynamic_instructions_O3 : 25
          // ------------------------------- 
          // static_instructions_Ofast : 25
          // dynamic_instructions_Ofast : 25
          // ------------------------------- 
          // static_instructions_Os : 25
          // dynamic_instructions_Os : 25
          // ------------------------------- 
          // static_instructions_Oz : 25
          // dynamic_instructions_Oz : 25
          // ------------------------------- 

          unsigned long resource_mem_flags = 255;
        
          int _len_priv0 = 65025;
          struct sja1000_priv * priv = (struct sja1000_priv *) malloc(_len_priv0*sizeof(struct sja1000_priv));
          for(int _i0 = 0; _i0 < _len_priv0; _i0++) {
              priv[_i0].write_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].read_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].can.clock.freq = ((-2 * (next_i()%2)) + 1) * next_i();
        
        
        
          }
        
          int _len_pdata0 = 65025;
          struct sja1000_platform_data * pdata = (struct sja1000_platform_data *) malloc(_len_pdata0*sizeof(struct sja1000_platform_data));
          for(int _i0 = 0; _i0 < _len_pdata0; _i0++) {
              pdata[_i0].osc_freq = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          sp_populate(priv,pdata,resource_mem_flags);
          free(priv);
          free(pdata);
        
        break;
    }


    // big-arr-10x
    case 2:
    {
          // static_instructions_O0 : 44
          // dynamic_instructions_O0 : 44
          // ------------------------------- 
          // static_instructions_O1 : 25
          // dynamic_instructions_O1 : 25
          // ------------------------------- 
          // static_instructions_O2 : 25
          // dynamic_instructions_O2 : 25
          // ------------------------------- 
          // static_instructions_O3 : 25
          // dynamic_instructions_O3 : 25
          // ------------------------------- 
          // static_instructions_Ofast : 25
          // dynamic_instructions_Ofast : 25
          // ------------------------------- 
          // static_instructions_Os : 25
          // dynamic_instructions_Os : 25
          // ------------------------------- 
          // static_instructions_Oz : 25
          // dynamic_instructions_Oz : 25
          // ------------------------------- 

          unsigned long resource_mem_flags = 10;
        
          int _len_priv0 = 100;
          struct sja1000_priv * priv = (struct sja1000_priv *) malloc(_len_priv0*sizeof(struct sja1000_priv));
          for(int _i0 = 0; _i0 < _len_priv0; _i0++) {
              priv[_i0].write_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].read_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].can.clock.freq = ((-2 * (next_i()%2)) + 1) * next_i();
        
        
        
          }
        
          int _len_pdata0 = 100;
          struct sja1000_platform_data * pdata = (struct sja1000_platform_data *) malloc(_len_pdata0*sizeof(struct sja1000_platform_data));
          for(int _i0 = 0; _i0 < _len_pdata0; _i0++) {
              pdata[_i0].osc_freq = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          sp_populate(priv,pdata,resource_mem_flags);
          free(priv);
          free(pdata);
        
        break;
    }


    // empty
    case 3:
    {
          // static_instructions_O0 : 44
          // dynamic_instructions_O0 : 44
          // ------------------------------- 
          // static_instructions_O1 : 25
          // dynamic_instructions_O1 : 25
          // ------------------------------- 
          // static_instructions_O2 : 25
          // dynamic_instructions_O2 : 25
          // ------------------------------- 
          // static_instructions_O3 : 25
          // dynamic_instructions_O3 : 25
          // ------------------------------- 
          // static_instructions_Ofast : 25
          // dynamic_instructions_Ofast : 25
          // ------------------------------- 
          // static_instructions_Os : 25
          // dynamic_instructions_Os : 25
          // ------------------------------- 
          // static_instructions_Oz : 25
          // dynamic_instructions_Oz : 25
          // ------------------------------- 

          unsigned long resource_mem_flags = ((-2 * (next_i()%2)) + 1) * next_i();
        
          int _len_priv0 = 1;
          struct sja1000_priv * priv = (struct sja1000_priv *) malloc(_len_priv0*sizeof(struct sja1000_priv));
          for(int _i0 = 0; _i0 < _len_priv0; _i0++) {
              priv[_i0].write_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].read_reg = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
          priv[_i0].can.clock.freq = ((-2 * (next_i()%2)) + 1) * next_i();
        
        
        
          }
        
          int _len_pdata0 = 1;
          struct sja1000_platform_data * pdata = (struct sja1000_platform_data *) malloc(_len_pdata0*sizeof(struct sja1000_platform_data));
          for(int _i0 = 0; _i0 < _len_pdata0; _i0++) {
              pdata[_i0].osc_freq = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].cdr = ((-2 * (next_i()%2)) + 1) * next_i();
          pdata[_i0].ocr = ((-2 * (next_i()%2)) + 1) * next_i();
        
          }
        
          sp_populate(priv,pdata,resource_mem_flags);
          free(priv);
          free(pdata);
        
        break;
    }

    default:
        usage();
        break;

    }

    return 0;
}
